import 'dart:io';

import 'package:my_flutter_core/services/http_request_service.dart';

class FileService {
  final String _url = '/file';
  final HttpRequestService _httpRequestService = HttpRequestService();

  /// Uploads current user own avatar file by base64 content.
  ///
  /// [flutter_uploader] does not work on Android 10. The behavior is the uploading action is not triggered.
  /// Uploading via base64 is alternative option to do it at this moment.
  Future<String> uploadOwnAvatarByBase64(File avatar) async {
    final res = await _httpRequestService.uploadByBase64(
      '$_url/upload-own-avatar-by-base64',
      avatar,
    );

    return res.payload;
  }
}
